<template>
  <div class="hospital-info-container">
    <div class="hospital-info">
      <div class="system-buttons">
        <span @click="selectTab('PublicHealthTable')"
              :class="{ 'button': true, 'selected': selectedTab === 'PublicHealthTable' }"
        >
          医院信息管理
        </span>
        <span
          @click="selectTab('FamilyDoctorTable')"
          :class="{ 'button': true, 'selected': selectedTab === 'FamilyDoctorTable' }"
        >
          组织管理
        </span>
        <span
          @click="selectTab('PerformanceTable')"
          :class="{ 'button': true, 'selected': selectedTab === 'PerformanceTable' }"
        >
          医生管理
        </span>
      </div>
    </div>
    <div class="hospital-info">
      <!-- 动态加载组件 -->
      <component :is="selectedTab" :key="selectedTab"></component>
    </div>
  </div>
</template>

<script>
import PublicHealthTable from '../components/PublicHealthTable.vue';
import FamilyDoctorTable from '../components/FamilyDoctorTable.vue';
import PerformanceTable from '../components/PerformanceTable.vue';

export default {
  name: "Index",
  data() {
    return {
      // 当前选中的标签页值，默认显示第一个
      selectedTab: 'PublicHealthTable',
    };
  },
  methods: {
    selectTab(tab) {
      console.log('Selecting tab:', tab); // 调试信息
      this.selectedTab = tab;
    }
  },
  components: {
    PublicHealthTable,
    FamilyDoctorTable,
    PerformanceTable
  }
};
</script>

<style scoped>
.hospital-info-container {
  padding: 20px;
  background: #F5F5F4;
}

.hospital-info {
  /*border: 1px solid red;*/
  /*border-radius: 10px;*/
  padding: 10px;
  background-color: white;
  margin-bottom: 20px;
}

.system-buttons {
  display: flex;
  align-items: center;
  /*border: 1px solid #e5e6e7;*/
  width: 100%;
  height: 60px;
  /*margin: 10px;*/
  padding: 0 10px;
  font-size: 18px;
  font-weight: bold;
  color: #5a5e66;
}

.button {
  margin-right: 20px; /* 设置间隔为20px */
  cursor: pointer;
  position: relative;
  padding: 10px 0;
}

.button:hover,
.button.selected {
  color: green;
}

.button::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 2px;
  background-color: transparent;
  transition: background-color 0.3s ease;
}

.button:hover::after,
.button.selected::after {
  background-color: green;
}

.info-table {
  width: 100%;
  border-collapse: collapse;
}

.info-table th,
.info-table td {
  padding: 10px;
  text-align: left;
}

.hospital-image {
  width: 30px;
  height: 30px;
  border-radius: 5px;
  margin-bottom: 10px;
}

.map-image {
  width: 230px;
  height: 260px;
  border-radius: 5px;
  margin-bottom: 10px;
}
</style>
